//
// CPSMaterial.java
// Copyright (C) 2010  "Naush" <naush _ hotmail _ fr>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>./* ----------------------------------------------------------------------------







package org.ryzom.nel.threed;

import org.ryzom.nel.misc.CRGBA;
import org.ryzom.nel.misc.IStream;

public class CPSMaterial {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  public CPSMaterial(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  public static long getCPtr(CPSMaterial obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        nel3dJNI.delete_CPSMaterial(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public CPSMaterial() {
    this(nel3dJNI.new_CPSMaterial(), true);
  }

  public void serialMaterial(IStream f) {
    nel3dJNI.CPSMaterial_serialMaterial(swigCPtr, this, IStream.getCPtr(f), f);
  }

  public void setBlendingMode(CPSMaterial.TBlendingMode mode) {
    nel3dJNI.CPSMaterial_setBlendingMode(swigCPtr, this, mode.swigValue());
  }

  public CPSMaterial.TBlendingMode getBlendingMode() {
    return CPSMaterial.TBlendingMode.swigToEnum(nel3dJNI.CPSMaterial_getBlendingMode(swigCPtr, this));
  }

  public void forceModulateConstantColor(boolean force, CRGBA col) {
    nel3dJNI.CPSMaterial_forceModulateConstantColor__SWIG_0(swigCPtr, this, force, CRGBA.getCPtr(col), col);
  }

  public void forceModulateConstantColor(boolean force) {
    nel3dJNI.CPSMaterial_forceModulateConstantColor__SWIG_1(swigCPtr, this, force);
  }

  public void forceTexturedMaterialStages(long numStages) {
    nel3dJNI.CPSMaterial_forceTexturedMaterialStages(swigCPtr, this, numStages);
  }

  public void enableZTest(boolean enabled) {
    nel3dJNI.CPSMaterial_enableZTest(swigCPtr, this, enabled);
  }

  public boolean isZTestEnabled() {
    return nel3dJNI.CPSMaterial_isZTestEnabled(swigCPtr, this);
  }

  public void setZBias(float value) {
    nel3dJNI.CPSMaterial_setZBias(swigCPtr, this, value);
  }

  public float getZBias() {
    return nel3dJNI.CPSMaterial_getZBias(swigCPtr, this);
  }

  public final static class TBlendingMode {
    public final static TBlendingMode add = new TBlendingMode("add");
    public final static TBlendingMode modulate = new TBlendingMode("modulate");
    public final static TBlendingMode alphaBlend = new TBlendingMode("alphaBlend");
    public final static TBlendingMode alphaTest = new TBlendingMode("alphaTest");

    public final int swigValue() {
      return swigValue;
    }

    public String toString() {
      return swigName;
    }

    public static TBlendingMode swigToEnum(int swigValue) {
      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
        return swigValues[swigValue];
      for (int i = 0; i < swigValues.length; i++)
        if (swigValues[i].swigValue == swigValue)
          return swigValues[i];
      throw new IllegalArgumentException("No enum " + TBlendingMode.class + " with value " + swigValue);
    }

    private TBlendingMode(String swigName) {
      this.swigName = swigName;
      this.swigValue = swigNext++;
    }

    private TBlendingMode(String swigName, int swigValue) {
      this.swigName = swigName;
      this.swigValue = swigValue;
      swigNext = swigValue+1;
    }

    private TBlendingMode(String swigName, TBlendingMode swigEnum) {
      this.swigName = swigName;
      this.swigValue = swigEnum.swigValue;
      swigNext = this.swigValue+1;
    }

    private static TBlendingMode[] swigValues = { add, modulate, alphaBlend, alphaTest };
    private static int swigNext = 0;
    private final int swigValue;
    private final String swigName;
  }

}
